import { ref } from "vue";
import { defineStore } from "pinia";
import { getCategoryRequest } from "@/apis/layout";


/* 
    setup写法:
        ref() 就是 state 属性
        computed() 就是 getters
        function() 就是 actions
*/


export const useCategoryStore = defineStore("category", () => {
	// state 导航列表数据
	const categoryList = ref([]);

    // action 获取导航数据的方法
	const getCategory = async () => {
		const resp = await getCategoryRequest();
		/* console.log(resp);
		console.log(resp.result); */

		// 构造响应式数据
		categoryList.value = resp.result;
	};
    return { categoryList, getCategory };
});
